home *** CD-ROM | disk | FTP | other *** search
- /* append.c: Append a formatted string to another string */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
-
- char *append(char *s, char *fmt, ...)
- {
- if (s && fmt)
- {
- va_list args;
- va_start(args,fmt);
- vsprintf(s+strlen(s),fmt,args);
- va_end(args);
- }
- return s;
- }
-
- main()
- {
- char s[81] = "We're";
- append(s," number %d!\n",1);
- puts(s);
- return 0;
- }
-
- Output:
- We're number 1!
-